package com.cyzy.Utils;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;

import java.util.Date;

public class TokenUtils {
    private static String secret = "nihao"; // 用于签名的密钥
   public  static  String creatToken(String value){
       long currentTime = System.currentTimeMillis()+30*60*1000;  //30分钟
       Date date = new Date(currentTime);
       String token= JWT.create()
               .withAudience(value)
               .withExpiresAt(date)  //过期时间
               .sign(Algorithm.HMAC256(secret));  // 对称加密算法，密钥
       return token;
   }
}
